var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var url = require('url');
var app = express();

app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, '/webapp')));


// app.all('*.html', function(req, res, next){
//     console.log(req.query)
//     if(req.query.PAJAX != 'true'){
//         res.sendfile("./webapp/index.html");
//     }
// });

app.use(function(req, res, next){
    if(req.query.PAJAX != 'true' && !req.query.PAJAX){
        res.sendfile("./webapp/index.html");
    }
});

app.listen(3001,function(){
    console.log(2)
});

app.on('listening', function(){
    console.log(1)
});


module.exports = app;
